package br.com.comanda.util;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

import br.com.comanda.dao.autosql.annotations.ForeignKey;

/**
 * Classe utilitária para manipular anotações
 * 
 * @author Thiago
 * @since 17/01/2013
 */
public class AnnotationUtils {

	public static List<Annotation> getForeignKeyFieldAnnotation(
			Class<?> middleTableClass) {
		List<Annotation> annotations = new ArrayList<Annotation>();

		for (Field field : middleTableClass.getDeclaredFields()) {
			for (Annotation ann : field.getDeclaredAnnotations()) {
				if (ann instanceof ForeignKey) {
					annotations.add(ann);
				}
			}
		}

		return annotations;
	}

}
